[None][fix] fix PEFT page accumulation in MaxUtilizationPolicy scheduler#13528
[None][fix] fix PEFT page accumulation in MaxUtilizationPolicy scheduler#13528achartier wants to merge 2 commits intoNVIDIA:mainfrom
Conversation
In MaxUtilizationPolicy._try_scheduling_request, num_scheduled_peft_pages was passed by value and never returned, so the caller's accumulator stayed at 0 across all requests. This caused the per-batch PEFT page cap to be checked against 0 already-scheduled pages for every request, potentially over-admitting LoRA tasks beyond the device cache limit. Fix mirrors the C++ reference (in capacityScheduler.cpp) return the updated count from _try_scheduling_request and accumulate it in the caller. Add a unit test that fails before the fix (3 tasks admitted when only 2 fit within max_pages=25) and passes after. Signed-off-by: Aurelien Chartier <2567591+achartier@users.noreply.github.com>
📝 WalkthroughWalkthroughThe changes modify the scheduler's PEFT page tracking mechanism in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/unittest/_torch/executor/test_py_scheduler.py (1)
2076-2100: Regression coverage is solid, and QA integration list updates are unnecessary for this unit-test-only change.This test cleanly reproduces the accumulation bug and verifies the intended cap behavior under
MAX_UTILIZATION.
As per coding guidelines, if a PR only touches unittest or narrow unit scope, QA integration test-list updates are unnecessary or optional.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unittest/_torch/executor/test_py_scheduler.py` around lines 2076 - 2100, The test test_max_utilization_peft_page_accumulation demonstrates that PyCapacityScheduler under CapacitySchedulerPolicy.MAX_UTILIZATION must accumulate PEFT page usage across admitted requests; ensure MockPeftCacheManager(max_pages=25, pages_per_request=10) behavior is used by PyCapacityScheduler.schedule_request so that cumulative pages from admitted tasks are tracked and the third request is rejected. Locate the test test_max_utilization_peft_page_accumulation and the scheduling logic in PyCapacityScheduler.schedule_request and confirm the scheduler queries peft_cache_manager (MockPeftCacheManager) for current allocated pages and adds the candidate request's pages_per_request before admitting; if accumulation is missing, update schedule_request to sum existing allocated PEFT pages plus the new request's pages and enforce max_pages when deciding to admit or reject. Ensure the test asserts len(fitting) == 2 still passes after the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/unittest/_torch/executor/test_py_scheduler.py`:
- Line 2097: The test unpacks three values from scheduler.schedule_request into
fitting, disagg, paused but only fitting is used; rename the unused unpacked
variables to underscore-prefixed names (e.g., _disagg and _paused) to satisfy
RUF059. Update the unpacking at the call to scheduler.schedule_request([r0, r1,
r2]) so it assigns fitting, _disagg, _paused and leave all other references to
fitting unchanged.
---
Nitpick comments:
In `@tests/unittest/_torch/executor/test_py_scheduler.py`:
- Around line 2076-2100: The test test_max_utilization_peft_page_accumulation
demonstrates that PyCapacityScheduler under
CapacitySchedulerPolicy.MAX_UTILIZATION must accumulate PEFT page usage across
admitted requests; ensure MockPeftCacheManager(max_pages=25,
pages_per_request=10) behavior is used by PyCapacityScheduler.schedule_request
so that cumulative pages from admitted tasks are tracked and the third request
is rejected. Locate the test test_max_utilization_peft_page_accumulation and the
scheduling logic in PyCapacityScheduler.schedule_request and confirm the
scheduler queries peft_cache_manager (MockPeftCacheManager) for current
allocated pages and adds the candidate request's pages_per_request before
admitting; if accumulation is missing, update schedule_request to sum existing
allocated PEFT pages plus the new request's pages and enforce max_pages when
deciding to admit or reject. Ensure the test asserts len(fitting) == 2 still
passes after the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: dab3f1ba-2ceb-4816-b02e-c09f4ccd41b5
📒 Files selected for processing (2)
tensorrt_llm/_torch/pyexecutor/scheduler/scheduler.pytests/unittest/_torch/executor/test_py_scheduler.py
Signed-off-by: Aurelien Chartier <2567591+achartier@users.noreply.github.com>
|
/bot run --disable-fail -fast |
|
PR_Github #45948 Bot args parsing error: usage: /bot [-h] |
|
/bot run --disable-fail-fast |
|
PR_Github #45950 [ run ] triggered by Bot. Commit: |
|
PR_Github #45950 [ run ] completed with state
|
Summary by CodeRabbit
Bug Fixes
Tests
Description
In MaxUtilizationPolicy._try_scheduling_request, num_scheduled_peft_pages was passed by value and never returned, so the caller's accumulator stayed at 0 across all requests. This caused the per-batch PEFT page cap to be checked against 0 already-scheduled pages for every request, potentially over-admitting LoRA tasks beyond the device cache limit.
Fix mirrors the C++ reference (in capacityScheduler.cpp) return the updated count from _try_scheduling_request and accumulate it in the caller.
Add a unit test that fails before the fix (3 tasks admitted when only 2 fit within max_pages=25) and passes after.
Test Coverage
Added new test
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.